<?php
include_once "xAP-functions/webincludes.php";



$now=date("Y-m-d H:i:s");


$sql="select * from xAP_Telephone_Log order by LogID DESC Limit 10";
$results=dbquery($sql);

//display
$body=  "<Table class='widget'>";
foreach($results as $row){
if($row["CallName"]==""){ $row["CallName"]=$row["CallNumber"];}

// change icon for not answered
$dir=substr($row["Direction"],0,3);
if ($row["Answered"]=="No"){$dir="no_".$dir;}



$body.=  "<tr>
<TD><img src='/switchboard/images/".$dir.".gif'></td>
<TD>".$row["CallName"]."</td>
<TD>".date("H:m d/m",strtotime($row["CallDate"]))."</td>
</tr>";

}
$body.= "</table>";

echo LayoutWidget("widget_LastCalls","Recent Calls",$body,$widgetID);
?>